package com.qingfeng.core.dao.qingfeng;

import com.qingfeng.core.config.database.BaseMapper;
import com.qingfeng.core.dao.BaseDao;
import com.qingfeng.core.entity.qingfeng.Complain;
import com.qingfeng.core.mapper.qingfeng.ComplainMapper;
import com.qingfeng.core.utils.UuidUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * @description: 投诉
 * @author:LWY
 * @date: 2017/10/16 17:15
 * @modified:
 */

@Repository
public class ComplainDao extends BaseDao<Complain> {

    @Autowired
    ComplainMapper complainMapper;

    @Override
    protected BaseMapper<Complain> getBaseMapper() {
        return complainMapper;
    }

    /**
     * 保存投诉
     *
     * @param user_id 用户id
     * @param task_id 任务id
     * @param type    投诉类型
     * @param message 投诉信息
     * @return
     */
    public Complain submit(String user_id, String task_id, String type, String message) {
        Complain complain = new Complain();
        String id = UuidUtil.generatorUUID();
        complain.setId(id);
        complain.setUser_id(user_id);
        complain.setTask_id(task_id);
        complain.setType(type);
        complain.setMessage(message);
        complain.setCreate_time(new Date());
        super.insert(complain);
        return complain;
    }
}
